/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-03-23
 * Time: 15:42
 */



public class TestState {
    public static Thread t;
    public static void main(String[] args) throws InterruptedException {
        Counter counter = new Counter();
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 5000; i++) {
                synchronized (counter) {
                    counter.add();
                    System.out.println(t.getState());
                }

            }
        });
        thread1.start();
        t = Thread.currentThread();
        for (int i = 0; i < 5000; i++) {
            synchronized (counter) {
                counter.add();
            }
        }
    }
}
